from view import user_ui, order_ui
from controller import user_control, order_control

if __name__ == '__main__':
    # 当前逻辑： 一个uesr_ui对应一个user_control对应一个order_control对应一个order_ui
    user_control = user_control.UserController()
    order_control = order_control.OrderController(user_control)
    # 但应该是一个controller对应多个user,所以应该是每次创建一个user_control，要‘顶掉’上一个user—_control
    # 反正不能两个人同时在线，能也处理不了

    user_ui = user_ui.UserUI(user_control)
    order_ui = order_ui.OrderUI(order_control)

    # user_ui_1 = user_ui.UserUI(user_control_1)
    # order_ui_1 = order_ui.OrderUI(order_control_1)
    #
    # user_control_2 = user_control.UserController()
    # user_ui_2 = user_ui.UserUI(user_control_2)

    while True:
        print('-'*20)
        print('欢迎使用商品订单管理系统')
        print('1. 账号管理')
        print('2. 订单管理')
        print('3. 退出')
        choice = input('请输入您的选择：')
        if choice == '1':
            user_ui.user_menu()
        elif choice == '2':
            if not user_control.current_user:
                print('请先登录')
                continue
            else:
                order_ui.order_menu()
        else:
            print('退出系统')
            break

    # print(order_control_1.user_controller.current_user)
    # user_ui_1.user_controller.login('admin', '123')
    # print(order_control_1.user_controller.current_user)
    # user_ui_2.user_controller.login('cust', '123')
    # print(order_control_1.user_controller.current_user)
